package com.hontech.pastacooking.activity.fragment.sub

import android.view.View
import android.widget.TextView
import com.hontech.pastacooking.R
import com.hontech.pastacooking.activity.view.CheckView
import com.hontech.pastacooking.conn.MainProto
import com.hontech.pastacooking.utils.S

class FridgeStatusDlg (view: View) {

    private val cv0 = view.findViewById<CheckView>(R.id.id_cv_fridge_0)
    private val cv1 = view.findViewById<CheckView>(R.id.id_cv_fridge_1)
    private val cv2 = view.findViewById<CheckView>(R.id.id_cv_fridge_2)
    private val cv3 = view.findViewById<CheckView>(R.id.id_cv_fridge_3)
    private val cv4 = view.findViewById<CheckView>(R.id.id_cv_fridge_4)
    private val cv5 = view.findViewById<CheckView>(R.id.id_cv_fridge_5)
    private val cv6 = view.findViewById<CheckView>(R.id.id_cv_fridge_6)
    private val cv7 = view.findViewById<CheckView>(R.id.id_cv_fridge_7)
    private val cv8 = view.findViewById<CheckView>(R.id.id_cv_fridge_8)
    private val cv9 = view.findViewById<CheckView>(R.id.id_cv_fridge_9)
    private val cv10 = view.findViewById<CheckView>(R.id.id_cv_fridge_10)
    private val cv11 = view.findViewById<CheckView>(R.id.id_cv_fridge_11)
    private val cv12 = view.findViewById<CheckView>(R.id.id_cv_fridge_12)
    private val cv13 = view.findViewById<CheckView>(R.id.id_cv_fridge_13)
    private val cv14 = view.findViewById<CheckView>(R.id.id_cv_fridge_14)
    private val cv15 = view.findViewById<CheckView>(R.id.id_cv_fridge_15)

    private val tvTemp = view.findViewById<TextView>(R.id.id_tv_fridge_temp)

    fun update() {
        val s = MainProto.fridge

        cv0.setChecked(s.sw.isSetBit(0))
        cv1.setChecked(s.sw.isSetBit(1))
        cv2.setChecked(s.sw.isSetBit(2))
        cv3.setChecked(s.sw.isSetBit(3))
        cv4.setChecked(s.sw.isSetBit(4))
        cv5.setChecked(s.sw.isSetBit(5))
        cv6.setChecked(s.sw.isSetBit(6))
        cv7.setChecked(s.sw.isSetBit(7))
        cv8.setChecked(s.sw.isSetBit(8))
        cv9.setChecked(s.sw.isSetBit(9))
        cv10.setChecked(s.sw.isSetBit(10))
        cv11.setChecked(s.sw.isSetBit(11))
        cv12.setChecked(s.sw.isSetBit(12))
        cv13.setChecked(s.sw.isSetBit(13))
        cv14.setChecked(s.sw.isSetBit(14))
        cv15.setChecked(s.sw.isSetBit(15))
        tvTemp.text = "${S.t62}:${s.tempValue()}℃"
    }
}